<?php session_start(); ?>
<html class="no-js" lang="en">

<head>
	<title>Sparsus</title>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" />
	<meta name="format-detection" content="telephone=no" />

	<!--<link rel="shortcut icon" type="image/ico" href="images/favicon.ico" />-->
	<link rel="apple-touch-icon" href="images/apple-touch-icon.png" />

	<link rel="stylesheet" href="css/reset.css" />
	<link rel="stylesheet" href="css/utils.css" />
	<link rel="stylesheet" href="css/layout.css" />
	<link rel="stylesheet" href="css/typography.css" />
	<link rel="stylesheet" href="css/lists.css" />
	<link rel="stylesheet" href="css/forms.css" />
	<link rel="stylesheet" href="css/blocks.css" />
	<link rel="stylesheet" href="css/media-queries.css" />

	<script src="js/json2.js"></script>
	<script src="js/zepto.js"></script>
	<script src="js/m-trapeze.js"></script>
	<script src="js/m-carousel.js"></script>
	<script src="js/m-statusbar.js"></script>
	
	<!-- we used modernizr's geoloc code to detect phone's geolocation. It works but we can do it natively using navigator. so not needed -->
	<script src="js/modernizr.geoloc.js"></script>
	
	<script type="text/javascript">
	function init() {
		var geo = document.getElementById("geo");
		if (Modernizr.geolocation) {	//if modernizr is used, use modernizr.geolocation here or navigator.geolocation.
			var l = "<div><b>From:</b> <input type='text' name='start' placeholder='Current Location' /><br/></div>";
		} else {
			var l = "<div><b>From:</b> <input type='text' name='start' /><br/></div>";
		}
		var oDiv = document.createElement('div');
		oDiv.innerHTML = l;
		geo.appendChild(oDiv);
	}
	</script>
	
</head>

<body onload="init()">
	<div id="Wrapper">
		<header id="Chrome">
			<div id="Logo"></div>
		</header>

<div id="Content">
	<div id="route">
		<div id="block">
			<div class="hdBlue">Route</div>
			
			<p>
			<strong>Note:</strong> After you click submit, please allow access to your geographic location if asked.
			</p>
			
			<form action="" method="post">
				<div id="geo"></div>
				<b>To:</b> 
<?php 
echo $_REQUEST['comp_name'];
$address = $_REQUEST['address'];
$comp_name = $_REQUEST['comp_name'];
$_SESSION['address'] = $address;
$_SESSION['comp_name'] = $comp_name;
$lat = $_REQUEST['lat'];
$lng = $_REQUEST['lng'];
$_SESSION['lat'] = $lat;
$_SESSION['lng'] = $lng;
?><br/>
<br/>
				Show Route As: <br/>
				<input type="radio" name="route_type" value="map" checked />&nbsp;<font style="font-size:18px">Map</font>&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="radio" name="route_type" value="text" /><font style="font-size:18px">Text</font><br/><br/>
				<input type="submit" name="submit" value="Submit" />
			</form>
		</div>
	</div>
</div>

<?php
if (isset($_POST['submit'])) {
	$type = $_POST['route_type'];
	$start = $_POST['start'];
	if ($type == 'map') {
		header("location: map.php?start=$start");
	}
	if ($type == 'text') {
		header("location: text.php?start=$start");
	}
}
?>

<?php include 'footer.php'?>